import 'package:json_annotation/json_annotation.dart';

part 'balance.g.dart';

@JsonSerializable()
class BalanceDetailModel {
  /// 支付名称
  String payName;

  /// 支付时间
  String payTime;

  /// 支付金额
  double payAmount;

  /// 账户余额
  double balance;

  /// 支付类型(收入or支出)
  BalanceTypeEnum type;

  BalanceDetailModel(
      {required this.payName,
      required this.payTime,
      required this.payAmount,
      required this.balance,
      this.type = BalanceTypeEnum.income});

  factory BalanceDetailModel.fromJson(Map<String, dynamic> json) =>
      _$BalanceDetailModelFromJson(json);

  Map<String, dynamic> toJson() => _$BalanceDetailModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

enum BalanceTypeEnum {
  /// 收入
  income(1, '收入', '#333333'),

  /// 支出
  disburse(2, '支出', '#CC0000');

  final int value;
  final String text;
  final String textColor;

  const BalanceTypeEnum(this.value, this.text, this.textColor);
}
